const app = getApp(); //引入导航
var util = require('../../utils/common.js'); //引入公共JS
var time = require('../../utils/utils.js'); // 引入时间戳转换时间
import { SubmitJqOrder } from 'SubmitJqOrder_model.js';
var wxParse = require('../../wxParse/wxParse.js'); //引入
var JqOrder = new SubmitJqOrder();
var dataName = '';
var idcards = '';
var cydate = '';
var xendtime = ''; //截止日期
var xstartime = ''; //开始日期
var M = ''; // 当前月
var D = ''; //当前日
var item_id = ''; //对接接口id
var item_name = ''; //接口名称
var dz = ''; //地址（主要检查有没有地址）

Page({
  data: {
    showIcon: true,
    //显示返回键以及首页
    timeFlag: true,
    //日历默认隐藏
    buttonClicked1: false,
    //向左日历默认可以点击
    buttonClicked2: false,
    //向右日历默认可以点击
    simplePrice: "",
    //单价
    knowFlag: true,
    //入园须知默认隐藏
    num: "1",
    //默认选择的数量是1
    aid: "",
    //aidcurrentDayList
    qyid: "",
    //区域
    idcards: '',
    //是否需要身份证
    currentDate: "",
    dayList: '',
    currentDayList: '',
    currentObj: '',
    currentDay: '',
    cydate: '',
    nowtime: '',
    noLogin: false,
    //未登录
    lineLogin: true,
    //已登录
    date: '',
    //当前时间
    idaddress: true,
    popup: false,
    //购票须知是否显示
    serviceIs: "是",
    //是否同意购票须知
    serviceIs_agreement: '否',
    jq_restriction: 0,
    //限购数量,
    resizeTimer: null,
    shorttitle: '',
    lastTime: 0
  },
  onLoad: function (options) {
    console.log('景点支付',options); //查询姓名和手机号

    JqOrder.getinfo(res => {
      this.setData({
        _name: res.name,
        _tel: res.tel,
        _address: res.address,
        _IdCard: res.IdCard
      });
    }); //查询地址

    JqOrder.getAddress(res => {
      for (var i = 0; i < res.length; i++) {
        res[i]['state'];

        if (res[i]['state'] == 1) {
          console.log(res[i]);
          var res2 = res[i]['straddress'] + res[i]['address'];
          console.log(res2);
          dz = res;
          this.setData({
            name: res[i]['truename'],
            moblie: res[i]['moblie'],
            address: res2,
            res: res
          });
        }
      }
    });

    if (options.aid == 89317) {
      var etc = 1;
      this.setData({
        etc: etc
      });
    } else {
      var etc = 0;
      this.setData({
        etc: etc
      });
    }

    var z = options.z;
    this.setData({
      z: z
    });
    var aid = options.aid;
    var qyid = options.id;
    this.data.aid = aid;
    this.data.qyid = qyid;

    this._onLoad(); //获取日期

    var currentObj = this.getCurrentDayString();
    this.setData({
      currentDate: currentObj.getFullYear() + '/' + (currentObj.getMonth() + 1) + '/' + currentObj.getDate(),
      currentDay: currentObj.getDate(),
      currentObj: currentObj,

      /*获取当前的年、月*/
      currentYear: currentObj.getFullYear(),
      currentMonth: currentObj.getMonth() + 1
    });
    this.setSchedule(currentObj); //页面打开判断是否登陆过
  },

  _onLoad: function () {
    var num = this.data.num; //数量
    JqOrder.getJqcontent(this.data.aid, this.data.qyid, res => {
      console.log(res);
      if (res == "error") {
        tt.reLaunch({
          url: '/pages/index/index'
        });
      } else {
        this.setData({
          kttime: res.kttime
        });
        var time_limit = res['time_limit'];
        var ywdate = res['ywdate'];

        if (ywdate == '是') {
          this.setData({
            ywdate: false
          });
        } else {
          this.setData({
            ywdate: true
          });
        }
        if (time_limit == 1) {
          this.setData({
            time_limit: false
          });
        } else {
          this.setData({
            time_limit: true
          });
        }

        var idaddress = res['idaddress'];
        if (idaddress == '是') {
          this.setData({
            idaddress: false
          });
        }

        var xadvance = res['xadvance'];
        this.setData({
          xxx: xadvance
        });
        var ber = typeof xadvance;

        if (ber != 'number') {
          var week = res['week'];
          var week2 = week.split(",");
          var week3 = [];
          week2 = week2.reverse();
          for (var i in week2) {
            if (week2[i] == 1) {
              week3[i] = '周一';
            }
            if (week2[i] == 2) {
              week3[i] = '周二';
            }
            if (week2[i] == 3) {
              week3[i] = '周三';
            }
            if (week2[i] == 4) {
              week3[i] = '周四';
            }
            if (week2[i] == 5) {
              week3[i] = '周五';
            }
            if (week2[i] == 6) {
              week3[i] = '周六';
            }
            if (week2[i] == 7) {
              week3[i] = '周日';
            }
          }

          var xvalidity_time = res['xvalidity_time'];
          item_name = res['item_name'];
          item_id = res['item_id'];
          wxParse.wxParse('xlongName', 'html', res.xlongName, this, 5);
          var price = res.xyhprice; //单价

          cydate = res.uptime;
          xstartime = res.xstartime;
          xendtime = res.xendtime; //截止时间

          xstartime = xstartime.substring(0, 10);
          xendtime = xendtime.substring(0, 10);
          cydate = time.formatTimeTwo(cydate, 'Y-m-d'); //时间戳转换成时间

          var that = this;
          var currentObj = that.data.currentObj;
          var Y = currentObj.getFullYear(); // 年
          M = currentObj.getMonth() + 1; // 月
          D = currentObj.getDate(); // 日
          M = fill_zero_prefix(M); // 补零处理
          D = fill_zero_prefix(D);
          var dqsj = Y + '-' + M + '-' + D; // 格式化处理

          function fill_zero_prefix(num) {
            // 补零处理函数
            return num < 10 ? "0" + num : num;
          }

          new Date(dqsj.replace(/-/g, "/"));
          var dqsj2 = new Date(dqsj.replace(/-/g, "/")).getTime();
          new Date(xstartime.replace(/-/g, "/"));
          var xstartime2 = new Date(xstartime.replace(/-/g, "/")).getTime(); // 如果当前时间大于开始时间

          if (dqsj2 > xstartime2) {
            this.setData({
              dqsj: dqsj,
              // 当前时间
              cydate: xendtime,
              //截止时间
              date: dqsj // 点击时间

            });
          } else {
            //当前时间小于开始时间就
            this.setData({
              dqsj: xstartime,
              // 当前时间
              cydate: xendtime,
              //截止时间
              date: xstartime // 点击时间

            });
          }
        } else {
          if (xadvance >= 1) {
            var xadvance2 = xadvance;
            var xadvance3 = xadvance2 * 86400; //提前的时间
          } else {
            var xadvance3 = xadvance * 3600; //提前的时间
          }

          var week = res['week'];
          var week2 = week.split(",");
          var week3 = [];
          week2 = week2.reverse();

          for (var i in week2) {
            if (week2[i] == 1) {
              week3[i] = '周一';
            }
            if (week2[i] == 2) {
              week3[i] = '周二';
            }
            if (week2[i] == 3) {
              week3[i] = '周三';
            }
            if (week2[i] == 4) {
              week3[i] = '周四';
            }
            if (week2[i] == 5) {
              week3[i] = '周五';
            }
            if (week2[i] == 6) {
              week3[i] = '周六';
            }
            if (week2[i] == 7) {
              week3[i] = '周日';
            }
          }

          var xvalidity_time = res['xvalidity_time'];

          if (xvalidity_time == null) {
            var xvalidity_time = '立即生效';
          }

          item_name = res['item_name'];
          item_id = res['item_id'];
          wxParse.wxParse('xlongName', 'html', res.xlongName, this, 5);
          var price = res.xyhprice; //单价

          cydate = res.uptime;
          xstartime = res.xstartime;
          xendtime = res.xendtime; //截止时间

          xstartime = xstartime.substring(0, 10);
          xendtime = xendtime.substring(0, 10);

          var _day2 = Number(xendtime.split("-")[2]);

          xendtime = xendtime.split("-")[0] + "-" + xendtime.split("-")[1] + "-" + _day2;
          cydate = time.formatTimeTwo(cydate, 'Y-m-d'); //时间戳转换成时间

          var that = this;
          var currentObj = that.data.currentObj;
          var Y = currentObj.getFullYear(); // 年
          M = currentObj.getMonth() + 1; // 月
          D = currentObj.getDate(); // 日
          M = fill_zero_prefix(M); // 补零处理
          D = fill_zero_prefix(D);
          var dqsj = Y + '-' + M + '-' + D; // 格式化处理

          function fill_zero_prefix(num) {
            // 补零处理函数
            return num < 10 ? "0" + num : num;
          }

          var dqsj2 = new Date(dqsj.replace(/-/g, "/")).getTime();
          var xstartime2 = new Date(xstartime.replace(/-/g, "/")).getTime(); // 如果当前时间大于项目开始时间

          if (xadvance3 > 86400) {
            dqsj2 = dqsj2 / 1000;
            dqsj = dqsj2 + xadvance3;
            dqsj = time.formatTimeTwo(dqsj, 'Y-m-d'); //时间戳转换成时间

            xstartime2 = xstartime2 / 1000;

            if (dqsj2 > xstartime2) {
              this.setData({
                dqsj: dqsj,
                // 当前时间
                cydate: xendtime,
                //截止时间
                date: dqsj // 点击时间

              });
            } else {
              //当前时间小于开始时间就
              this.setData({
                dqsj: xstartime,
                // 当前时间
                cydate: xendtime,
                //截止时间
                date: xstartime // 点击时间

              });
            }
          } else {
            dqsj2 = dqsj2 / 1000;
            dqsj = dqsj2 + xadvance3;
            dqsj = time.formatTimeTwo(dqsj, 'Y-m-d'); //时间戳转换成时间

            xstartime2 = xstartime2 / 1000;

            if (dqsj2 > xstartime2) {
              this.setData({
                dqsj: dqsj,
                // 当前时间
                cydate: xendtime,
                //截止时间
                date: dqsj // 点击时间

              });
            } else {
              //当前时间小于开始时间就
              this.setData({
                dqsj: xstartime,
                // 当前时间
                cydate: xendtime,
                //截止时间
                date: xstartime // 点击时间

              });
            }
          }
        }

        this.setData({
          simplePrice: res.xyhprice,
          jq_restriction: res.restriction
        });
        var totalPrice = Math.round(num * price * 100) / 100;
        idcards = res.idcards;
        this.data.idcards = idcards;

        if (res.spzt != "出售中") {
          this.showMessage('此项目已售完');
        }

        var array = [];

        for (var i = 0; i < 1; i++) {
          array[i] = i;
        }

        this.setData({
          'Jqcontent': res,
          totalPrice: totalPrice,
          'aid': this.data.aid,
          'shorttitle': res.shorttitle,
          'qyid': this.data.qyid,
          'array': array,
          xvalidity_time: xvalidity_time,
          week3: week3
        });
      }
    });
  },
  //根据日期判断星期几
  weekjudgment: function (date) {
    var week;
    var num = date.getDay();

    switch (num) {
      case 0:
        week = "周日";
        break;

      case 1:
        week = "周一";
        break;

      case 2:
        week = "周二";
        break;

      case 3:
        week = "周三";
        break;

      case 4:
        week = "周四";
        break;

      case 5:
        week = "周五";
        break;

      default:
        week = '周六';
        break;
    }

    return week;
  },

  //点击日期选择
  bindDateChange(e) {
    var weekdate = this.weekjudgment(new Date(e.detail.value));

    if (!this.data.week3.includes(weekdate)) {
      tt.showToast({
        title: '您选择的是' + weekdate + '不在使用日期之内',
        icon: 'none',
        dauration: 2000
      });
    } else {
      this.setData({
        date: e.detail.value
      });
    }

    var xxx = e.target.dataset.xxx;
    var ber2 = typeof xxx;
    var number = 'number';

    if (ber2 == number) {
      var ber3 = xxx % 24;

      if (ber3 != 0) {
        tt.showToast({
          title: '请提前' + xxx + '天预订'
        });
      }
    }
  },
  //数量加
  addClick: function () {
    var num = this.data.num;
    var price = this.data.simplePrice; //单价

    var restrictionnum = this.data.jq_restriction; //限制购票数量
    // 数量最多可以选择

    if (restrictionnum != 0) {
      if (num < restrictionnum) {
        num++;
      }

      if (num == restrictionnum) {
        this.showMessage('购票数量最多为' + restrictionnum + '张！');
      }
    } else {
      if (num < 20) {
        num++;
      }

      if (num == 20) {
        this.showMessage('购票数量最多为20张！');
      }
    } // 只有大于一件的时候，才能normal状态，否则disable状态


    var minusStatus = num < 1 ? 'disabled' : 'normal';
    var totalPrice = Math.round(num * price * 100) / 100;
    var array = [];

    for (var i = 0; i < num; i++) {
      array[i] = i;
    } // 将数值与状态写回


    this.setData({
      num: num,
      minusStatus: minusStatus,
      totalPrice: totalPrice,
      array: array
    });
  },
  /* 点击减号 */
  reduceClick: function () {
    var num = this.data.num; //选择的数量
    var price = this.data.simplePrice; //单价
    // 如果大于1时，才可以减

    if (num > 1) {
      num--;
    }

    var array = [];

    for (var i = 0; i < num; i++) {
      array[i] = i;
    } // 只有大于一件的时候，才能normal状态，否则disable状态


    var minusStatus = num <= 1 ? 'disabled' : 'normal';
    var totalPrice = Math.round(num * price * 100) / 100; // 将数值与状态写回

    this.setData({
      num: num,
      minusStatus: minusStatus,
      totalPrice: totalPrice,
      array: array
    });
  },

  /* 监听input框 */
  nameInput: function (e) {
    //监听实名登记姓名输入
    var that = this;
    var num = e.detail.value;
    var price = this.data.simplePrice; //单价

    var restrictionnum = this.data.jq_restriction; //限制购票数量

    var totalPrice = num * price;
    var totalPrice2 = 1 * price; //最低一张

    var totalPrice3 = restrictionnum * price; //最多

    if (restrictionnum != 0) {
      if (num < 1) {
        that.setData({
          num: "1",
          totalPrice: totalPrice2
        });
        that.showMessage('购票数量最少为1张！');
      } else if (num > restrictionnum) {
        that.setData({
          num: restrictionnum,
          totalPrice: totalPrice3
        });
        that.showMessage('购票数量最多为' + restrictionnum + '张！');
      } else {
        that.setData({
          num: num,
          messageFlag: true,
          totalPrice: totalPrice
        });
      }
    } else {
      if (num < 1) {
        that.setData({
          num: "1",
          totalPrice: totalPrice2
        });
        that.showMessage('购票数量最少为1张！');
      } else if (num > 20) {
        that.setData({
          num: 20,
          totalPrice: 20 * price
        });
        that.showMessage('购票数量最多为20张！');
      } else {
        that.setData({
          num: num,
          messageFlag: true,
          totalPrice: totalPrice
        });
      }
    }
  },
  //支付
  payBtn: function (e) {
    console.log(222, e);
    var that = this;
    var source = tt.getStorageSync('source');
    var mMid = tt.getStorageSync('mMid');
    var z = e.detail.value.z;

    if (idcards == '是') {
      console.log('是');
      var telRule = /^(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[1|3|5|8|9])[0-9]{8}$/;
      var IdRule2 = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
      var nameRule = /^[\u2E80-\u9FFF]+$/;
      var data = e.detail.value;
      var date = this.weekjudgment(new Date(data.CYdate));

      if (data.Kname == '') {
        this.showMessage('请输入姓名');
      }else if(!nameRule.test(data.Kname)){
        this.showMessage('请输入正确的中文字符')
      } else if (that.data.idaddress == false && data.address == '') {
        this.showMessage('请输入通讯地址');
      } else if (data.Kmoblie == '') {
        this.showMessage('请输入手机号码');
      } else if (!telRule.test(data.Kmoblie)) {
        this.showMessage('手机号码格式不正确');
      } else if (this.data.serviceIs_agreement == '否') {
        this.showMessage('请先同意退换货说明和用户服务协议');
      } else if (!this.data.week3.includes(date)) {
        this.showMessage('您选择的出行时间不在可使用范围内');
      } else if (this.data.serviceIs == "否") {
        console.log(this.data.serviceIs);
        this.setData({
          popup: true
        });
        return 1;
      } else {
        var aa = "";
        var bb;

        for (var i = 0; i < data.num; i++) {
          aa = "Kcard" + '' + i;
          bb = "Kname" + '' + i;

          if (data[bb] == "") {
            this.showMessage('请输入姓名');
            return 1;
          } else if(!nameRule.test(data[bb])){
            this.showMessage('请输入正确的中文字符')
            return 1;
          } else if (data[aa] == '') {
            this.showMessage('请输入身份证号码');
            return 1;
          } else if (!IdRule2.test(data[aa])) {
            this.showMessage('请输入正确的身份证号码');
            return 1;
          } else if (data[aa] == data['Kcard' + (i + 1)]) {
            this.showMessage('身份证号码不能重复');
            return 1;
          }
        }

        var jqrow = {
          'data': data,
          'name': data.Kname,
          'tel': data.Kmoblie,
          'Kcard': data.Kcard0,
          'aid': this.data.aid,
          'qyid': this.data.qyid,
          'simplePrice': this.data.simplePrice,
          'CYdate': data.CYdate,
          'num': data.num,
          'price': data.totalPrice,
          'item_id': item_id,
          'item_name': item_name,
          'xtitle': e.detail.value.xtitle,
          'z': z,
          'source': source,
          'mMid': mMid,
          'shorttitle': this.data.shorttitle,
          'address': data.address,
          "port_type" :"tt"
        };
        this.data.jqrow = jqrow;
        var that = this;
        tt.showLoading({
          title: '请稍后...'
        });
        console.log(111, this.data.jqrow);
        JqOrder.jqOrder(this.data.jqrow, res => {
          console.log('支付', res);
          tt.hideLoading();

          if (res.nochushou == 10000) {
            this.showMessage('此项目已售完');
            return 1;
          } else if (res.nochushou == 20000) {
            this.showMessage('出行日期有误，请注意预定提示');
          } else if (res.nochushou == 30000) {
            this.showMessage('超过购票数量');
          } else if (res.data) {
            that.setData({
              _val: 2,
              fromCartFlag: false
            });
            tt.showLoading({
              title: '正在支付请等待'
            });

            that._execPay(res.data);
          } else {
            tt.showModal({
              title: '下单失败',
              content: '请联系客服 400-800-7000',
              showCancel: false,
              success: function (res) {
                tt.redirectTo({
                  url: '../jqdetail/jqdetail?id='+that.data.aid 
                });
              }
            });
          }
        });
      }
    } else {
      console.log('否');
      var telRule = /^(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[1|3|5|8|9])[0-9]{8}$/;
      var nameRule = /^[\u2E80-\u9FFF]+$/;
      var data = e.detail.value;
      var date = this.weekjudgment(new Date(data.CYdate));

      if (data.Kname == '') {
        this.showMessage('请输入姓名');
      }else if(!nameRule.test(data.Kname)){
        this.showMessage('请输入正确的中文字符')
      } else if (that.data.idaddress == false && data.address == '') {
        this.showMessage('请输入通讯地址');
      } else if (data.Kmoblie == '') {
        this.showMessage('请输入手机号码');
      } else if (!telRule.test(data.Kmoblie)) {
        this.showMessage('手机号码格式不正确');
      } else if (this.data.serviceIs_agreement == '否') {
        this.showMessage('请先同意退换货说明和用户服务协议');
      } else if (!this.data.week3.includes(date)) {
        this.showMessage('您选择的出行时间不在可使用范围内');
      } else if (this.data.serviceIs == "否") {
        console.log(this.data.serviceIs);
        this.setData({
          popup: true
        });
      } else {
        var jqrow = {
          'data': '',
          'name': data.Kname,
          'tel': data.Kmoblie,
          'Kcard': '',
          'aid': this.data.aid,
          'qyid': this.data.qyid,
          'simplePrice': this.data.simplePrice,
          'CYdate': data.CYdate,
          'num': data.num,
          'price': data.totalPrice,
          'item_id': item_id,
          'item_name': item_name,
          'xtitle': e.detail.value.xtitle,
          'z': z,
          'source': source,
          'mMid': mMid,
          'address': data.address,
          "port_type" :"tt"
        };
        this.data.jqrow = jqrow;
        var that = this;
        tt.showLoading({
          title: '请稍后...'
        });
        console.log(222, this.data.jqrow);
        JqOrder.jqOrder(this.data.jqrow, res => {
          console.log('不实名', res);
          tt.hideLoading();
          if (res.nochushou == 10000) {
            this.showMessage('此项目已售完');
          } else if (res.nochushou == 20000) {
            this.showMessage('出行日期有误，请注意预定提示');
          } else if (res.nochushou == 30000) {
            this.showMessage('超过购票数量');
          } else if (res.data) {
            that.setData({
              _val: 2,
              fromCartFlag: false
            });
            tt.showLoading({
              title: '正在支付请等待'
            });

            that._execPay(res.data);
          } else {
            tt.showModal({
              title: '下单失败',
              content: '请联系客服 400-800-7000',
              showCancel: false,
              success: function (res) {
                tt.redirectTo({
                  url: '../jqdetail/jqdetail?id='+that.data.aid 
                });
              }
            });
          }
        });
      }
    }
  },
  // 在一定时间内连续点击只会触发一次
  subbtn: function (e) {
    var that = this;
    var now = new Date().getTime();
    if (now - that.data.lastTime <= 2000) {
      return;
    }
    that.setData({
      lastTime: now
    });
    that.payBtn(e);
  },

  /*
   *开始支付
   * params:
   * id - {int}订单id
   */
  _execPay: function (orderinfo) {
    console.log(orderinfo)
    setTimeout(function () {
      tt.hideLoading();
    }, 1000);
    JqOrder.JqexecPay(orderinfo, statusCode => {
      console.log('开始支付', statusCode);

      if (statusCode != 0) {
        //JqOrder.getFaPiao(id, (res) =>{});
        tt.showLoading({
          title: '支付成功'
        }); //显示2秒隐藏加载提示

        setTimeout(function () {
          tt.hideLoading();
        }, 1000);
        var flag = statusCode == 1; 
        //发送短信
        // JqOrder.getSMS(id, (res) => { });
        //微信接口
        // JqOrder.notify((res) => {
        //   console.log(res)
        // })

        tt.redirectTo({
          url: '../jqOrder/jqOrder'
        });
      } else {
        tt.showModal({
          title: '下单失败',
          content: '请联系客服 400-800-7000',
          showCancel: false,
          success: function (res) {
            tt.redirectTo({
              url: '../jqOrder/jqOrder'
            });
          }
        });
      }
    });
  },
  //弹框
  showMessage: function (text) {
    var that = this;
    that.setData({
      showMessage: true,
      messageContent: text
    });
    setTimeout(function () {
      that.setData({
        showMessage: false,
        messageContent: ''
      });
    }, 2000);
  },
  timeClose: function () {
    this.setData({
      timeFlag: true
    });
  },
  getCurrentDayString: function () {
    var objDate = this.data.currentObj;

    if (objDate != '') {
      return objDate;
    } else {
      var c_obj = new Date();
      var a = c_obj.getFullYear() + '/' + (c_obj.getMonth() + 1) + '/' + c_obj.getDate();
      return new Date(a);
    }
  },
  setSchedule: function (currentObj) {
    var that = this;
    var m = currentObj.getMonth() + 1;
    var Y = currentObj.getFullYear();
    var d = currentObj.getDate();
    var dayString = Y + '/' + m + '/' + currentObj.getDate();
    var currentDayNum = new Date(Y, m, 0).getDate();
    var currentDayWeek = currentObj.getUTCDay() + 1;
    var result = currentDayWeek - (d % 7 - 1);
    var firstKey = result <= 0 ? 7 + result : result;
    var currentDayList = [];
    var f = 0;

    for (var i = 0; i < 42; i++) {
      let data = [];

      if (i < firstKey - 1) {
        currentDayList[i] = '';
      } else {
        if (f < currentDayNum) {
          currentDayList[i] = f + 1;
          f = currentDayList[i];
        } else if (f >= currentDayNum) {
          currentDayList[i] = '';
        }
      }
    }

    that.setData({
      currentDayList: currentDayList
    });
  },
  disagree: function () {
    this.setData({
      serviceIs: "否",
      popup: false
    });
  },
  agree: function () {
    this.setData({
      serviceIs: "是",
      popup: false
    });
  },
  //选择是否同意用户协议
  switchChange: function (e) {
    var _val = e.detail.value;
    console.log(_val);

    if (_val == true) {
      this.setData({
        serviceIs_agreement: "是",
        _val: 1
      });
    } else {
      this.setData({
        serviceIs_agreement: "否",
        _val: 2
      });
    }
  },
  // 拨打电话
  calling: function () {
    tt.makePhoneCall({
      phoneNumber: '188-6035-1905'
    });
  },
  //分享
  onShareAppMessage: function () {
    util.sharePage();
  } // 获取头像
  // getUserProfile(e){
  //   var that=this
  //     wx.getUserProfile({
  //       desc: '用于完善您的资料信息', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
  //       success: (res) => {
  //         console.log(res)
  //         var nickName = res.userInfo.nickName;
  //         var avatarUrl = res.userInfo.avatarUrl;
  //         var Name = {
  //           'nickName': nickName,
  //           'avatarUrl': avatarUrl
  //         };
  //         JqOrder.getNickName(Name, (res) => {
  //           console.log(res)
  //         })
  //         util.noLogin(that)
  //       }
  //     })
  // }

});